#!/bin/bash

pid=`ps -ef |grep java|grep kl-dt-gateway.jar |awk '{print $2}'`
if [ ! $pid  ]; then
    echo "server is not start"
else 
    kill -15  ${pid}
fi

BINDIR=`dirname "${BASH_SOURCE-$0}"`
BINDIR=`cd "$BINDIR">/dev/null; pwd`
APPHOME=`cd "$BINDIR/.." > /dev/null; pwd`

# get java bin path
if [ -z "$JAVA" ]; then
    if [ "$JAVA_HOME" != "" ]; then
      JAVA=$JAVA_HOME/bin/java
    else
      JAVA=$(which java)
    fi
fi

if [ "$JAVA" = "" ] || [ ! -f "$JAVA" ]; then
    echo "Can not find java, check environment please."
    exit 1
fi

APPBIN="$JAVA"

JAVA_MEM_OPTS=" -XX:+PrintClassHistogram -XX:+UseZGC -XX:+UseStringDeduplication -Xms2G -Xmx4G "
JAVA_OPTS="-DIGNITE_PERFORMANCE_SUGGESTIONS_DISABLED=true -Djava.net.preferIPv4Stack=true --add-opens=java.base/jdk.internal.access=ALL-UNNAMED --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.util.calendar=ALL-UNNAMED --add-opens=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-opens=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.sql/java.sql=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED"

#nohup /opt/apps/jdk1.8.0_101/bin/java -jar -Xms2048m -Xmx2048m /opt/apps/kl-dt-gateway/kl-dt-gateway.jar >> /opt/apps/kl-dt-gateway/kl-dt-gateway.log 2>&1 &
#不生成启动日志
nohup $APPBIN -jar $JAVA_MEM_OPTS $JAVA_OPTS $APPHOME/kl-dt-gateway.jar > /dev/null 2>&1 &
